home *** CD-ROM | disk | FTP | other *** search
- #ifndef COLAE.H
-
- #define COLAE.H
-
- // Cola de enteros, este algoritmo simula una cola de enteros.
-
- #include "mdefs.h"
-
- #include <conio.h>
-
- #include <stdlib.h>
-
- #include <alloc.h>
-
-
-
-
-
- typedef struct {
-
- void *Siguiente;
-
- int entero;
-
- } ElementoColaEnteros;
-
-
-
- typedef struct {
-
- ElementoColaEnteros *Inicio;
-
- ElementoColaEnteros *Fin;
-
- } ColaE;
-
-
-
- typedef ElementoColaEnteros *pColaE;
-
-
-
-
-
- #define COLAE_TODO_OK 0
-
- #define COLAE_MEMORIA_INSUFICIENTE 1
-
-
-
- #define ColaEVacia(x) ( ((*x).Fin) == NULL)
-
- #define ColaETope(x) ((x->entero)
-
-
-
-
-
- void ColaEAnula( ColaE *cola)
-
- {
-
- (*cola).Inicio = NULL;
-
- (*cola).Fin = NULL;
-
- }// end ColaGenericaAnula
-
-
-
- WORD ColaEMete(ColaE *cola, int numero)
-
- {
-
- pColaE elem;
-
-
-
- elem= (pColaE) malloc(sizeof(ElementoColaEnteros));
-
- if( elem != NULL) {
-
- (*elem).entero = numero;
-
- (*elem).Siguiente = NULL;
-
- if( ColaEVacia(cola)) {
-
- (*cola).Fin = elem;
-
- (*cola).Inicio = elem;
-
- } else {
-
- (*((*cola).Inicio)).Siguiente = elem;
-
- (*cola).Inicio= elem;
-
- }// end if
-
- return(COLAE_TODO_OK);
-
- } else
-
- return (COLAE_MEMORIA_INSUFICIENTE);
-
- }// end ColaGenericaMete
-
-
-
- int ColaESaca(ColaE *cola)
-
- {
-
- pColaE elem= cola->Fin;
-
- int numero = elem->entero;
-
- (*cola).Fin = elem->Siguiente;
-
- if ( (*cola).Fin == NULL)
-
- (*cola).Inicio = NULL;
-
- free(elem);
-
- return(numero);
-
- }// end ColaGenericaSaca
-
-
-
- #endif define ColaG